export const RECEIVE_MESSAGE = "receiveMessage";

export interface Message {
  info: string;
  from: string;
}

function createReceiveMessageEvent(message: Omit<Message, "from">) {
  return new CustomEvent(RECEIVE_MESSAGE, {
    detail: {
      ...message,
      from: "Vite子应用child1",
    },
  });
}

export function dispatchReceiveMessageEvent(message: Omit<Message, "from">) {
  const event = createReceiveMessageEvent(message);
  window.dispatchEvent(event);
}
